﻿using IntelligentAgriculture.Contracts.Interface;
using IntelligentAgriculture.Domain.Entity;
using IntelligentAgriculture.WebAPI.Application.Command.SheepRescissionCommand;
using MediatR;

namespace IntelligentAgriculture.WebAPI.Application.CommandHandler.SheepRescissionCommandHandler
{
    /// <summary>
    /// 新增羊只转舍
    /// </summary>
    public class AddSheepRescissionCommandHandler : IRequestHandler<AddSheepRescissionCommand, Results<int>>
    {
        private readonly ISheepRescissionService _sheepRescissionService;

        public AddSheepRescissionCommandHandler(ISheepRescissionService sheepRescissionService)
        {
            _sheepRescissionService = sheepRescissionService;
        }

        public async Task<Results<int>> Handle(AddSheepRescissionCommand request, CancellationToken cancellationToken)
        {
            var result = await _sheepRescissionService.AddSheepRescission(request.Input);
            return Results<int>.DataResult(result);
        }
    }
}
